<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
    <div class="site_map" align="left">Trang chủ <img src="/onlinemarket/img/navbit-arrow-right.png"/> sản phẩm</div>
    <div class="heading">
        <div class="heading_left"></div>
        <div class="heading_right"></div>
        <div class="heading_center">
        	<h3>Sản Phẩm</h3>
        </div>
         <div class="table">
            <h1>&nbsp;</h1>
            <form method="post"  enctype="multipart/form-data" id="Product" action="/onlinemarket/products/save">
                <table style="padding-left: 50px;">
                <tr>
                    <td>
						<font color="red">*</font>Chon anh
                        <input type="file" name="data[picture]" value=""/>
                    </td>
                    <td>
                        <table>
                            <input type="hidden" id="id" name="id" value="<?php echo($iProduct['Product']['id']); ?>"/>
                            <tr>
                                <td><font color="red">*</font>Tên sản phẩm</td>
                                <td><input type="text" name="name" id="name" value="<?php echo($iProduct['Product']['name']); ?>"/></td>
                                <td style="width: 50px;">&nbsp;</td>
                                <td><font color="red">*</font>Giá sản phẩm</td>
                                <td><input type="text" name="price" id="price" value="<?php echo($iProduct['Product']['price']); ?>"/></td>
                            </tr>
                            <tr>
                                <td><font color="red">*</font>Số lượng</td>
                                <td><input type="text" name="quantity" id="quantity" value="<?php echo($iProduct['Product']['quantity']);?>"/> </td>
                                <td style="width: 30px;">&nbsp;</td>
                                <td><font color="red">*</font>Mô tả sản phẩm</td>
                                <td><textarea name="description" id="description" rows="5" cols="22"><?php echo($iProduct['Product']['description']); ?></textarea></td>
                            </tr>
                            <tr>
							<td>đánh giá</td>
							<td><input name="rating" type="text" id="rating" value="<?php echo($iProduct['Product']['rating']);?>" /></td>
							 <td style="width: 30px;">&nbsp;</td>
                                <td>Cửa hàng</td>
                                <td>
								<select name="shop_id" style="width:200;text-align:center">
								<?php foreach($ishop as $shop){ ?>
								 <option value="<?php echo($shop['Shop']['id']); ?>" ><?php echo($shop['Shop']['name']);  ?> </option>
								  <?php } ?>
								 </select>
								</td>
                            </tr>
                            <tr>
                                <td>Mã nhóm sản phẩm</td>
								<td><select name="product_group_id" id="product_group_id" style="width:200;text-align:center">
				 				<?php foreach($productgroup as $productg){ ?>
								<option value="<?php echo($productg['ProductGroup']['id']); ?>"><?php echo($productg['ProductGroup']['name']); ?> </option>
								<?php } ?>
								 </select>
								</td>
								
                                <td style="width: 30px;">&nbsp;</td>
                                <td>Nhà cung cấp</td>
                                <td>
									<select name="provider_id" id="provider_id" style="width:200;text-align:center">
										<?php foreach($providerList as $pro) { ?>
											<option value="<?php echo($pro['Provider']['id']); ?>" > <?php echo($pro['Provider']['name']); ?> </option>
										<?php } ?>
									</select>
								</td>
                            </tr>
                            <tr>
                                <td colspan="5" align="right">
                                    <input type="submit" value="Lưu" style="height: 25px; padding-top: 0.3em; font-size: 12px;"/>
                   					<input type="button" value="Hủy" style="height: 25px; padding-top: 0.3em; font-size: 12px;" onclick="onCancel();"/>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="padding-bottom: 0;"><hr /></td>
                </tr>
                <tr>
                    <td colspan="2" style="padding-top: 0;">Trường <font color="red">*</font> yêu cầu phải nhập</td>
                </tr>
                </table>
            </form>
            </div>
            <!-- hien thi chi thông tin sản pham-->
<table class="border" style="width: 100%;">
    <tr>
        <td colspan="10" align="right"><a href="/onlinemarket/products">Thêm sản phẩm mới</a></td>
    </tr>
    <tr>
        <th>Tên sản phẩm</th>
        <th>Giá sản phẩm</th>
        <th>Ảnh</th>
        <th>Số lượng</th>
        <th>Mô tả</th>
        <th>Đánh giá</th>
        <th>Nhóm sản phẩm</th>
        <th>Nhà sản xuất</th>
        <th>Shop</th>
		<th>Chức Năng</th>
    </tr>


<?php foreach ($products as $prod) : ?>
<tr>
    <td align="left"><?php echo($prod['Product']['name']); ?>&nbsp;</td>
    <td align="left"><?php echo(number_format($prod['Product']['price'],0,'.','.')); ?>&nbsp;</td>
    <td align="center"><img src="/onlinemarket/img/San_pham/<?php echo($prod['Product']['picture']); ?>" width="30"/></td>
    <td align="center"><?php echo($prod['Product']['quantity']); ?>&nbsp;</td>
    <td align="left"><?php echo($prod['Product']['description']); ?>&nbsp;</td>
	 <td align="center"><?php echo($prod['Product']['rating']); ?>&nbsp;</td>
	<?php foreach($productgroup as $productg):
								if($productg['ProductGroup']['id']==$prod['Product']['product_group_id']){ ?>
    <td align="center"><?php echo($productg['ProductGroup']['name']); } endforeach; ?>&nbsp;</td>
	
	<?php foreach($providerList as $pro) :
								if($pro['Provider']['id']==$prod['Product']['provider_id']){ ?>
    <td align="center"><?php echo($pro['Provider']['name']); }  endforeach; ?>&nbsp;</td>
	
	<td><?php foreach($ishop as $vshop) :
								if($vshop['Shop']['id']== $prod['Product']['shop_id']){ 
     echo($vshop['Shop']['name']); }  endforeach; ?>&nbsp;</td>
    
	<td align="center">
        <img style="cursor: pointer;" src="/onlinemarket/img/system/bt_edit.png" onclick="onEdit('/onlinemarket/products/index/<?php echo($prod['Product']['id']);?>')" alt="Sửa" title="Sửa"/>
        <img style="cursor: pointer;" src="/onlinemarket/img/system/bt_delete.png" onclick="onEdit('/onlinemarket/products/delete/?id=<?php echo($prod['Product']['id']);?>')" alt="Xóa" title="Xóa"/>
		 <img style="cursor: pointer;" src="/onlinemarket/img/system/view.bmp" onclick="onEdit('/onlinemarket/products/view/<?php echo($prod['Product']['id']);?>')" alt="xem" title="xem"/>
    </td>
</tr>
<?php endforeach; ?>

</table>
<div style="text-align: right;">
    <?php echo $this->Paginator->numbers();?>
    <?php echo $this->Paginator->prev('« Previous', null, null, array('class' => 'disabled')); ?>
    <?php echo $this->Paginator->next('Next »', null, null, array('class' => 'disabled')); ?>
</div>
</div>
<script>
function onEdit(link) {
        window.location = link;
    }
    function onCancel() {
        $('form').slideUp('slow');
    }
    function getQueryVariable(variable) {
        var query = window.location.search.substring(1);
        var vars = query.split('&');
        for (var i=0; i<vars.length; i++) {
            var pair = vars[i].split('=');
            if (pair[0] == variable) {
                return pair[1];
            }
        }
    };
</script>

</body>
</html>